//
//  Building.m
//  3DModelCollector
//
//  Created by Jing Zhang on 7/7/12.
//  Copyright (c) 2012 Tencent. All rights reserved.
//

#import "Building.h"
#import <CoreLocation/CoreLocation.h>

@implementation Building

@synthesize basicInfo = _basicInfo;

@synthesize AutoNavi_FID = _AutoNavi_FID;
@synthesize AutoNavi_setTID = _AutoNavi_setTID;
@synthesize AutoNavi_setType = _AutoNavi_setType;

@synthesize baseIndiceList = _baseIndiceList;
@synthesize baseAccuracy = _baseAccuracy;
@synthesize storeyInfoList = _storeyInfoList;
@synthesize baseStoreyHeight = _baseStoreyHeight;
@synthesize upperStoreyHeight = _upperStoreyHeight;

@synthesize photoInfoList = _photoInfoList;

- (id)init {
    
    self = [super init];
    if (self) {
        _basicInfo = [[BuildingBasicInfo alloc] init];
        
        _baseIndiceList = nil;
        _storeyInfoList = nil;
        
        _photoInfoList = [[NSMutableArray alloc] init];
    }
    
    return self;
}

- (void)dealloc {
    
    self.basicInfo = nil;
    
    self.baseIndiceList = nil;
    self.storeyInfoList = nil;
    self.photoInfoList = nil;
    
    [super dealloc];
}

#pragma mark - [NSCopying]

- (id)copyWithZone:(NSZone *)zone {
    
    Building* newBuilding = [[[self class] allocWithZone:zone] init];
    
    newBuilding.basicInfo = [self.basicInfo mutableCopy];
    
    newBuilding.AutoNavi_FID = self.AutoNavi_FID;
    newBuilding.AutoNavi_setTID = self.AutoNavi_setTID;
    newBuilding.AutoNavi_setType = self.AutoNavi_setType;
    
    newBuilding.baseIndiceList = [self.baseIndiceList mutableCopy];
    newBuilding.baseAccuracy = self.baseAccuracy;
    
    newBuilding.storeyInfoList = [self.storeyInfoList mutableCopy];
    newBuilding.baseStoreyHeight = self.baseStoreyHeight;
    newBuilding.upperStoreyHeight = self.upperStoreyHeight;
    
    newBuilding.photoInfoList = [self.photoInfoList mutableCopy];
    
    return newBuilding;
}

+ (Building*)createExperimentalBuilding {
    
    Building* oneBuilding = [[Building alloc] init];
    
    static double coors[] = {
        116.306675606389,  39.9822016913889,
        116.306429919167,  39.9815598569444,
        116.306395802778,  39.98147073,
        116.306338239167,  39.98147471,
        116.306300770833,  39.9814825275,
        116.306259429722,  39.9814939988889,
        116.306215094722,  39.9815172347222,
        116.306181968056,  39.9815328441667,
        116.306136934722,  39.9815302897222,
        116.306113740278,  39.9820303172222,
        116.306087845556,  39.9820308558333,
        116.306075314722,  39.9820373905556,
        116.306067533056,  39.9820483819444,
        116.306067458889,  39.9820557486111,
        116.306071204722,  39.9820646180556,
        116.306077834167,  39.9820727725,
        116.306091242500,  39.9820743483333,
        116.306125743611,  39.9820760858333,
        116.306134350278,  39.9820783616667,
        116.306137011389,  39.9820997469444
     /*
        113.93756659784198, 22.546569987651168,
        113.93767874689074, 22.547010741386188,
        113.93775482296638, 22.546995185395986,
        113.93778808870425, 22.547139337504802,
        113.93795554028770, 22.547102003160120,
        113.93783510989491, 22.546635322999578,
        113.93779763330414, 22.546589691965849,
        113.93775061211349, 22.546558579888739,
        113.93770359092282, 22.546551320403083,
          113.93763018172069, 22.546552357472493
      */
      };
  
    NSMutableArray* array = [[NSMutableArray alloc] initWithCapacity:1];
    for (int i = 0; i < sizeof(coors) / (2 * sizeof(double)); i++) {
        CGPoint pt = {coors[2 * i], coors[2 * i + 1]};
        NSValue* value = [NSValue valueWithCGPoint:pt];
        [array addObject:value];
    }
    oneBuilding.baseIndiceList = array;
    [array release];

    return oneBuilding;
}

@end
